﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MainApp
{
    public partial class ChangePassDlg: DevExpress.XtraEditors.XtraForm
    {
        public ChangePassDlg()
        {
            InitializeComponent();
        }

        private void LoginDialog_Load(object sender, EventArgs e)
        {
            btnOK.Enabled = false;
        }

        public string OldPassword { get{return txtOld.Text;} set{txtOld.Text = value;}}

        public string NewPassword { get { return txtNew.Text; } set { txtNew.Text = value; txtConfirm.Text = value; } }

        public bool getLogin()
        {
            return this.ShowDialog()==DialogResult.OK;
        }

        private void txtPassword_KeyDown(object sender, KeyEventArgs e)
        {
            
        }

        private void txtUserName_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                txtOld.Focus();
            }
        }

        private void LoginDialog_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                btnCancel.PerformClick();
            }
            else if (e.KeyCode == Keys.Enter)
            {
                if (btnOK.Enabled)
                {
                    btnOK.PerformClick();
                }
                else
                {
                    GetNextControl(sender as Control, true).Focus();
                }
            }
        }

        private void txtConfirm_TextChanged(object sender, EventArgs e)
        {
            btnOK.Enabled = (txtNew.Text.Length > 0) && (txtNew.Text == txtConfirm.Text);
        }
    }
}
